<?php
/**
 * Stachl
 *
 * LICENSE
 *
 * This source file is subject to the CC-GNU GPL license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/GPL/2.0/
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@stachl.me so we can send you a copy immediately.
 *
 * @category   Stachl
 * @package    Stachl_Controller
 * @copyright  Copyright (c) 2010 Stachl.me (http://www.stachl.me)
 * @license    http://creativecommons.org/licenses/GPL/2.0/     CC-GNU GPL License
 */

/**
 * @see Zend_Controller_Plugin_Abstract
 */
require_once 'Zend/Controller/Plugin/Abstract.php';

class Stachl_Controller_Plugin_Login extends Zend_Controller_Plugin_Abstract
{
	
	public function preDispatch()
	{
		if (!Zend_Auth::getInstance()->hasIdentity() && ($this->getRequest()->getControllerName() !== 'login')) {
			// If they aren't logged in they can't logout so we redirect
			// them to the login form
			return Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'login');
		}
	}
	
}